package com.szrt.scott.filter;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class JsonFilter extends BasicFilter {
	
	public  static void printJson(ServletRequest req,HttpServletResponse response) throws IOException {
		HttpServletRequest request = (HttpServletRequest) req;
		PrintWriter outer = response.getWriter();
		Object obj = request.getAttribute("jsonsObjectScott");
		String jieguo =obj.toString();
		outer.write(jieguo);
		outer.flush();
		outer.close();
	}
	
	@Override
	public void myFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		chain.doFilter(request, response);
		printJson(request, response);
	}

	
}
